<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateGroupsTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('groups', function(Blueprint $table)
		{
                    $table->engine = 'InnoDB';
                    $table->increments('id');
                    $table->string('name', 128);
                    $table->timestamps();
		});

		Schema::table('users', function(Blueprint $table) 
                {
                    $table->engine = 'InnoDB';
                    $table->integer('group_id')->references('id')->on('groups')->index();
                });
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::table('groups', function(Blueprint $table)
		{
                    Schema::drop('groups');
		});
		Schema::table('users', function(Blueprint $table)
		{
                    Schema::dropForeign('group_id');
		});
	}

}